<!DOCTYPE html>
<html lang="zh-cn">
<head>
   
    <link type="text/css" rel="stylesheet" href="/bundles/blog-common.css?v=KOZafwuaDasEedEenI5aTy8aXH0epbm6VUJ0v3vsT_Q1"/>
<link id="MainCss" type="text/css" rel="stylesheet" href="/skins/ThinkInside/bundle-ThinkInside.css?v=RRjf6pEarGnbXZ86qxNycPfQivwSKWRa4heYLB15rVE1"/>
<link type="text/css" rel="stylesheet" href="/blog/customcss/428549.css?v=%2fam3bBTkW5NBWhBE%2fD0lcyJv5UM%3d"/>

</head>
<body>
<a name="top"></a>

<div id="page_begin_html"></div><script>load_page_begin_html();</script>

<div id="topics">
	<div class = "post">
		<h1 class = "postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="https://www.cnblogs.com/frankdeng/p/9572014.html">Storm（二）CentOS7.5搭建Storm1.2.2集群</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div id="cnblogs_post_body" class="blogpost-body"><h2>一.Storm的下载</h2>
<p>官网下载地址：<a href="http://storm.apache.org/downloads.html" target="_blank">http://storm.apache.org/downloads.html</a></p>
<p>这里下载最新的版本storm1.2.2，进入之后选择一个镜像下载</p>
<p><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902132001286-1967343541.png" alt="" /></p>
<h2>二.Storm伪分布式安装</h2>
<h3>1.环境准备</h3>
<p>JDK 1.7+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;验证： java -version<br />Python 2.6.6+&nbsp; &nbsp; &nbsp; 验证：python -V</p>
<h3>2.解压安装包</h3>
<div class="cnblogs_code">
<pre>[admin@node21 software]$ tar zxvf apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>.tar.gz -C /opt/module/</pre>
</div>
<h3>3.创建logs文件目录</h3>
<div class="cnblogs_code">
<pre>[admin@node21 software]$ cd /opt/module/apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span><span style="color: #000000;">
[admin@node21 apache</span>-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ mkdir logs</pre>
</div>
<h3>4.启动storm</h3>
<ul>
<li>查看帮助</li>
</ul>
<div class="cnblogs_code">
<pre>[admin@node21 apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm help</pre>
</div>
<p>帮助如下</p>
<div class="cnblogs_code" onclick="cnblogs_code_show('cb45c3e8-1dcf-49e8-9368-36a246e3c20b')"><img id="code_img_closed_cb45c3e8-1dcf-49e8-9368-36a246e3c20b" class="code_img_closed" src="https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" alt="" /><img id="code_img_opened_cb45c3e8-1dcf-49e8-9368-36a246e3c20b" class="code_img_opened" style="display: none;" onclick="cnblogs_code_hide('cb45c3e8-1dcf-49e8-9368-36a246e3c20b',event)" src="https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" alt="" />
<div id="cnblogs_code_open_cb45c3e8-1dcf-49e8-9368-36a246e3c20b" class="cnblogs_code_hide">
<pre>[admin@node21 storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/<span style="color: #000000;">storm help
Commands:
    activate
    blobstore
    classpath
    deactivate
    dev</span>-<span style="color: #000000;">zookeeper
    drpc
    </span><span style="color: #0000ff;">get</span>-<span style="color: #000000;">errors
    heartbeats
    help
    jar
    kill
    kill_workers
    list
    localconfvalue
    logviewer
    monitor
    nimbus
    node</span>-health-<span style="color: #000000;">check
    pacemaker
    rebalance
    remoteconfvalue
    repl
    set_log_level
    shell
    sql
    supervisor
    ui
    upload</span>-<span style="color: #000000;">credentials
    version

Help: 
    help 
    help </span>&lt;command&gt;<span style="color: #000000;">

Documentation </span><span style="color: #0000ff;">for</span> the storm client can be found at http:<span style="color: #008000;">//</span><span style="color: #008000;">storm.apache.org/documentation/Command-line-client.html</span>
<span style="color: #000000;">
Configs can be overridden </span><span style="color: #0000ff;">using</span> one or more -c flags, e.g. <span style="color: #800000;">"</span><span style="color: #800000;">storm list -c nimbus.host=nimbus.mycompany.com</span><span style="color: #800000;">"</span></pre>
</div>
<span class="cnblogs_code_collapse">View Code</span></div>
<ul>
<li>启动Zookeeper</li>
</ul>
<div class="cnblogs_code">
<pre>[admin@node21 apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm dev-zookeeper &gt;&gt; ./logs/zk.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;</pre>
</div>
<ul>
<li>启动Nimbus</li>
</ul>
<div class="cnblogs_code">
<pre>[admin@node21 apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm nimbus &gt;&gt; ./logs/nimbus.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;</pre>
</div>
<ul>
<li>启动Storm UI</li>
</ul>
<div class="cnblogs_code">
<pre>[admin@node21 apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm ui &gt;&gt; ./logs/ui.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;</pre>
</div>
<ul>
<li>启动Supervisor</li>
</ul>
<div class="cnblogs_code">
<pre>[admin@node21 apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm supervisor &gt;&gt; ./logs/supervisor.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;</pre>
</div>
<ul>
<li>启动Logviewer</li>
</ul>
<div class="cnblogs_code">
<pre>[admin@node21 apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm logviewer ./logs/logviewer.out 2&gt;&amp;1 &amp;</pre>
</div>
<h3>5.查看进程</h3>
<p>&nbsp;<img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902200448453-5014627.png" alt="" /></p>
<h3>6.WebUI查看</h3>
<p>WebUI查看地址：<a href="http://node21:8080/" target="_blank">http://node21:8080/</a></p>
<p><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902201837362-1765041836.png" alt="" /></p>
<h2>三.Storm分布式集群安装</h2>
<p>官网集群配置文档：<a href="http://storm.apache.org/releases/1.2.2/Setting-up-a-Storm-cluster.html" target="_blank">http://storm.apache.org/releases/1.2.2/Setting-up-a-Storm-cluster.html</a></p>
<h3>1.集群部署</h3>
<table style="background-color: #27d8c9;" border="0">
<tbody>
<tr>
<td style="text-align: center;">IP</td>
<td>节点名称</td>
<td>Jdk，Python</td>
<td>Zookeeper</td>
<td>Nimbus</td>
<td>Supervisor</td>
</tr>
<tr>
<td>192.168.100.21</td>
<td>node21</td>
<td>Jdk，Python</td>
<td>Zookeeper</td>
<td>Nimbus</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>192.168.100.22</td>
<td>node22</td>
<td>Jdk，Python</td>
<td>Zookeeper</td>
<td>&nbsp;</td>
<td>Supervisor</td>
</tr>
<tr>
<td>192.168.100.23</td>
<td>node23</td>
<td>Jdk，Python</td>
<td>Zookeeper</td>
<td>&nbsp;</td>
<td>Supervisor</td>
</tr>
</tbody>
</table>
<p>Zookeeper集群安装参考：&nbsp;<a id="post_title_link_9018177" href="https://www.cnblogs.com/frankdeng/p/9018177.html" target="_blank">CentOS7.5搭建Zookeeper3.4.12集群与命令行操作</a></p>
<h3>2.安装环境解压安装包</h3>
<div class="cnblogs_code">
<pre>[admin@node21 software]$ tar zxvf apache-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>.tar.gz -C /opt/module/<span style="color: #000000;">
[admin@node21 software]$ cd </span>/opt/module/<span style="color: #000000;">
[admin@node21 module]$ mv apache</span>-storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>/ storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span><span style="color: #000000;">
[admin@node21 module]$ cd storm</span>-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span><span style="color: #000000;">
[admin@node21 storm</span>-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ mkdir logs</pre>
</div>
<h3>3.修改yaml配置文件</h3>
<div class="cnblogs_code">
<pre>[admin@node21 storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ vi conf/storm.yaml </pre>
</div>
<p><span><span>1）</span></span><span><span>storm.zookeeper.servers</span></span><span><span>：这是Storm集群的Zookeeper集群中的主机列表。</span></span></p>
<p>2<span><span>）</span></span><span><span>storm.local.dir</span></span><span><span>：Nimbus和Supervisor守护进程需要本地磁盘上的目录来存储少量状态（如jar，confs和类似的东西）。</span><span>您应该在每台计算机上创建该目录，为其提供适当的权限，然后使用此配置填写目录位置。</span></span></p>
<p><span><span>3）</span></span><span><span>nimbus.seeds</span></span><span><span>：工作节点需要知道哪些机器是主机的候选者才能下载拓扑罐和confs。</span></span></p>
<p><span><span><span><span>4）</span></span><span><span>supervisor.slots.ports</span></span><span><span>：对于每个工作者计算机，您可以使用此配置配置在该计算机上运行的工作程序数。</span><span>每个工作人员使用单个端口接收消息，此设置定义哪些端口可以使用。</span><span>如果您在此处定义了五个端口，那么Storm将分配最多五个工作人员在此计算机上运行。</span><span>如果定义三个端口，Storm最多只能运行三个端口。</span><span>默认情况下，此设置配置为在端口6700,6701,6702和6703上运行4个工作程序。</span></span></span></span></p>
<p><span><span><span><span><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902212418053-1388539987.png" alt="" /></span></span></span></span></p>
<h3>4.分发Storm到其他节点</h3>
<div class="cnblogs_code">
<pre>[admin@node21 module]$ scp -r storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>/<span style="color: #000000;"> node22:`pwd`
[admin@node21 module]$ scp </span>-r storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>/ node23:`pwd`</pre>
</div>
<h3>5.配置环境变量</h3>
<div class="cnblogs_code">
<pre>[admin@node21 module]$ sudo vi /etc/<span style="color: #000000;">profile
export STORM_HOME</span>=/opt/module/storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span><span style="color: #000000;">
export PATH</span>=$PATH:$STORM_HOME/<span style="color: #000000;">bin
[admin@node21 module]$ source </span>/etc/profile</pre>
</div>
<h3>6.启动集群</h3>
<ul>
<li>启动zookeeper集群，各个节点执行</li>
</ul>
<div class="cnblogs_code">
<pre>$ zkServer.sh start</pre>
</div>
<ul>
<li>启动storm集群</li>
</ul>
<p>node21上启动Nimbus，启动webUI</p>
<div class="cnblogs_code">
<pre>[admin@node21 storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm nimbus &gt;&gt; ./logs/nimbus.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;<span style="color: #000000;">
[admin@node21 storm</span>-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm ui &gt;&gt; ./logs/ui.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;</pre>
</div>
<p>node22和node23启动supervisor，按照配置，每启动一个supervisor就有了4个slots</p>
<div class="cnblogs_code">
<pre>[admin@node22 storm-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm supervisor &gt;&gt; ./logs/supervisor.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;<span style="color: #000000;">
[admin@node23 storm</span>-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">2</span>]$ ./bin/storm supervisor &gt;&gt; ./logs/supervisor.<span style="color: #0000ff;">out</span> <span style="color: #800080;">2</span>&gt;&amp;<span style="color: #800080;">1</span> &amp;</pre>
</div>
<h3>7.查看进程</h3>
<p><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902214907279-1648928089.png" alt="" /></p>
<p><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902214912284-258555848.png" alt="" /></p>
<p><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902214930247-1773078519.png" alt="" /></p>
<h3>8.查看WebUI</h3>
<p>WebUI查看地址：<a href="http://node21:8080/" target="_blank">http://node21:8080/</a></p>
<p><a href="http://node21:8080/" target="_blank"><img src="https://images2018.cnblogs.com/blog/1385722/201809/1385722-20180902215142763-1351049223.png" alt="" /></a></p>
<h3>9.编写storm服务脚本</h3>
<p>node21上&nbsp; &nbsp;start-stormCluster.sh</p>
<div class="cnblogs_code">
<pre>#!/bin/<span style="color: #000000;">bash
echo  </span><span style="color: #800000;">"</span><span style="color: #800000;">********************     正在启动nimbus服务     *******************</span><span style="color: #800000;">"</span><span style="color: #000000;">
ssh   admin@node21 </span><span style="color: #800000;">'</span><span style="color: #800000;">/opt/module/storm-1.2.2/bin/storm nimbus &gt;&gt; /opt/module/storm-1.2.2/logs/nimbus.out 2&gt;&amp;1 &amp;</span><span style="color: #800000;">'</span><span style="color: #000000;">
echo  </span><span style="color: #800000;">"</span><span style="color: #800000;">*********************    正在启动webUi服务   ******************</span><span style="color: #800000;">"</span><span style="color: #000000;">
ssh   admin@node21 </span><span style="color: #800000;">'/</span><span style="color: #800000;">opt/module/storm-1.2.2/bin/storm ui &gt;&gt; /opt/module/storm-1.2.2/logs/ui.out 2&gt;&amp;1 &amp;</span><span style="color: #800000;">'</span><span style="color: #000000;">
echo  </span><span style="color: #800000;">"</span><span style="color: #800000;">********************     正在启动supervisor服务     *******************</span><span style="color: #800000;">"</span><span style="color: #000000;">
ssh   admin@node22 </span><span style="color: #800000;">'</span><span style="color: #800000;">/opt/module/storm-1.2.2/bin/storm supervisor &gt;&gt; /opt/module/storm-1.2.2/logs/supervisor.out 2&gt;&amp;1 &amp;</span><span style="color: #800000;">'</span><span style="color: #000000;">
ssh   admin@node23 </span><span style="color: #800000;">'</span><span style="color: #800000;">/opt/module/storm-1.2.2/bin/storm supervisor &gt;&gt; /opt/module/storm-1.2.2/logs/supervisor.out 2&gt;&amp;1 &amp;</span><span style="color: #800000;">'</span><span style="color: #000000;">
echo  </span><span style="color: #800000;">"</span><span style="color: #800000;">******************      服务启动成功      *******************</span><span style="color: #800000;">"</span>*</pre>
</div>
<p>给脚本赋权限 ：chmod +x 脚本名称</p>
<h2>四.故障排除</h2>
<p>参考文档：<a href="http://storm.apache.org/releases/1.2.2/Troubleshooting.html" target="_blank">http://storm.apache.org/releases/1.2.2/Troubleshooting.html</a></p></div>

</body>
</html>
